package erQiao.yfl.app.common;

import java.io.Serializable;

/**
 * @author tiny.yx
 * @date 2018/07/18
 */
public class Result<T> implements Serializable {
    private static final long serialVersionUID = -1765186273030278701L;
    private boolean success;
    private String msg;
    private String errorCode;
    private T data;

    public static <T> Result<T> wrapSuccessResult(T data) {
        Result<T> result = new Result<T>();
        result.success = true;
        result.data = data;
        return result;
    }

    public static <T> Result<T> wrapErrorResult(String errorCode, String msg) {
        Result<T> result = new Result<T>();
        result.success = false;
        result.msg = msg;
        result.errorCode = errorCode;
        return result;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
